<include file="public@header" />
<style>
    .controls{ color:#999}
    .control-label{width:200px !important}
    .form-horizontal .control-group1{}
</style>

</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('index')}">{:lang('可视化墓区')}</a></li>
        <li class="active"><a href="">{:lang('插入墓位')}</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form  " action="{:url('add_tomb_col')}">
        <div class="control-group">
            <label  class="  control-label">墓区名称：</label>
            <div class="col-md-6 ">
                <input type="text" class="form-control" id="input-user_login" disabled name="user_login" value="{$tombarea_info.name}">
            </div>
        </div>
        <div class="control-group">
            <label for="rowid" class="  control-label">
               所属排位号 <span class="form-required">*</span>：</label>
            <div class="col-md-6 ">
                <select class="form-control" name="rowid" id="rowid" required>
                    <option value="">请选择所属排位号</option>
                    <foreach name="row_list" item="vo">
                        <option value="{$vo.rowID}" data-key="{$key+1}" >{$vo.num}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="control-group">
            <label for="input-num" class="  control-label">
                墓位编号<span class="form-required">*</span>：</label>
            <div class="col-md-6 ">
                <input type="hidden" name="tombarea_id" value="{$tombarea_info.id}" />
                <input type="hidden" name="selected_id_v" value="{$selected_id_v}" />
                <input type="hidden" name="cate_id" value="{$tombarea_info.cate_id}" />
                <input type="hidden" name="rows_num" id="rows_num" value="1 " />
                <input type="text" class="form-control" id="input-num" name="num" placeholder="请填写墓位编号" required>
            </div>
        </div>
        <div class="control-group">
            <label class="  control-label">
               墓位所在位置序号 <span class="form-required">*</span>：</label>
            <div class="col-md-6 ">
                <input type="number" min="1" class="form-control" id="column_num" name="column_num" required>
            </div>
        </div>
        <div class="control-group">
            <label  class="control-label">抵顶人：</label>
            <div class="col-md-6 ">
                <select class="form-control" name="reacher">
                    <option value="">请选择抵顶人</option>
                    <foreach name="reacher_list" item="vo">
                        <option value="{$vo.user_nickname}" >{$vo.user_nickname}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">状态：</label>
            <div class="col-md-6">
                <select name="status" class="form-control">
                    <option value="1">显示</option>
                    <option value="0">隐藏</option>
                </select>
            </div>
        </div>
        <div class="control-group" id="row">


        </div>
        <div class="control-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js?v={:time()}"></script>
<script>
    $('#rowid').click(function () {
        var rowid =$(this).val();
        $.ajax({
            url: "{:url('add_tomb_col')}",
            type: "get",
            dataType: "json",
            data: {'rowid': rowid, 'ajax': 1},
            success: function (result) {
                $('#row').html('');
                console.log(result)
                //在表格中生成N位
                var str = "<table class='table table-hover table-bordered table-list' style='width:auto; margin-right:5%;'><tr>";
                $.each(result,function (i,n) {
                    str += "<th style='width:120px'>" +
                        "<input type='text'  value='" + n.num + "' disabled class='form-control' style='width:100px;' /><br>" +
                        "<input type='hidden'   name='col["+i+"][id]'  value='" + n.colID + "'  ><br>" +
                        "<input type='number' min='1' class='form-control'  name='col["+i+"][column_num]'  value='" + n.column_num + "' style='width:90px;' ><br>" +
                        // "<input type='text' placeholder='抵顶人' name='reacher[]' class='form-control' style='width:100px; margin-top:5px' /><br>"+
                        "<select style='width:115px; margin-top:5px' class='form-control' name='col["+i+"][status]'>" +
                        "<option value='1'>显示</option><option value='2'>隐藏</option>" +
                        "</select>"
                    "</th>";
                })
                str += '</tr></table>';
                $('#row').append(str);
            }
        })
    })
    
</script>

</body>
</html>